package com.randioo.randioo_server_base.utils;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zsy
 * @Description:
 * @create 2018-01-16 13:50
 **/
public class AnnotationUtils {

    /**
     * @param
     * @description: 获得一个类的所有包含指定注解的字段
     * @return:
     * @author: zsy
     * @date: 2018/1/16 13:57
     */
    public static List<Field> getFieldListByAnnotation(Class aclass,
            Class<? extends Annotation> annotationClass) {
        List<Field> list = new ArrayList<>();
        for (Field field : aclass.getDeclaredFields()) {
            if (field.isAnnotationPresent(annotationClass)) {
                list.add(field);
            }
        }
        return list;
    }

}
